package com.hcxy.filetransform.adapter;

import java.text.SimpleDateFormat;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.hcxy.filetransform.R;
import com.hcxy.filetransform.domain.FileTranslateInfo;
import com.hcxy.filetransform.domain.TransformLog;
import com.hcxy.filetransform.util.ImageUtil;
import com.lidroid.xutils.view.annotation.ViewInject;

public class SendImageViewHolder extends BaseViewHolder<TransformLog> {

	@ViewInject(R.id.tv_time)
	private TextView tv_time;
	@ViewInject(R.id.iv_picture)
	private ImageView iv_picture;
	@ViewInject(R.id.file_progress)
	private ProgressBar progress_file;
	
	
	public SendImageViewHolder(Context context, ViewGroup root,
			OnRecyclerViewListener onRecyclerViewListener) {
		super(context, root, R.layout.item_chat_sent_image, onRecyclerViewListener);
	}

	@Override
	public void bindData(TransformLog t) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		String url = t.getData();
		ImageUtil.setPicture(url, R.drawable.android,iv_picture, null);
		String time =dateFormat.format(t.getDate()) ;
		tv_time.setText(time);
		if (t.isFinish() || t.getFilelength()<=t.getProgress()) {
			progress_file.setVisibility(View.GONE);
		}else{
			progress_file.setVisibility(View.VISIBLE);
			progress_file.setMax((int)(t.getFilelength()/1000));
			progress_file.setProgress((int)(t.getProgress()/1000));
		}
	}
	public void showTime(boolean isShow) {
	    tv_time.setVisibility(isShow ? View.VISIBLE : View.GONE);
	  }

}
